import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'numberWithComma',
})
export class NumberWithCommaPipe implements PipeTransform {

  transform(value: unknown, ...args: unknown[]): unknown {
    if (!value || typeof value !== 'number') {
      return value;
    }
    return value.toString().replace(/\B(?=(\d{4})+(?!\d))/g, ', ');
  }

}
